package cc3002;

/**
 * Weird Food extension. This Food may have extreme results when eaten.
 * @author Anibal Llanos Prado
 *
 */
public class MysteriousSandwich extends WeirdFood {
	
	/**
	 * Creates a Mysterious Sandwich with standard values. The name can't be modified
	 * nor the possible bites (5).
	 */
	public MysteriousSandwich(){

		this.sicknessLimit=8;
		this.badStackLimit=1;
		this.goodStackLimit=2;
		this.name="Mysterious Sandwich";
		this.remainingBites=5;
	}
	
	/**
	 * Bites the food. This method is overridden to modify it behavior. Now it has a random multiplier
	 * for giving mysteriousness to the Mysterious Sandwich.
	 * @param health The Health State of the biter.
	 */
	@Override
	public int bite(HealthState health){
		assert remainingBites!=0:"Nothing to eat";
		if(remainingBites==0)return 0;
		--remainingBites;
		int aux=(int)(caloriesPerBite*health.getFoodMultiplier()*randomMultiplier());
		modifyHealth(health);
		return aux;
	}
	
	/**
	 * Calculates a random multiplier, the very source of mysteriousness.
	 * @return A random multiplier between -1 and 3
	 */
	private double randomMultiplier(){
		return (Math.random()*4)-1;
	}
	
}
